package com.eduhzy.ttw.clazz.mvp.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.eduhzy.ttw.clazz.R;
import com.eduhzy.ttw.clazz.mvp.model.entity.EditGroupData;
import com.eduhzy.ttw.clazz.mvp.model.entity.ReviewStudentData;
import com.eduhzy.ttw.commonsdk.holder.AutoBaseViewHolder;
import com.eduhzy.ttw.commonsdk.http.CommonApi;

import java.util.List;

/**
 * @author xubo
 * @date 2018/12/6 17:04
 */
public class GroupSectionAdapter extends BaseSectionQuickAdapter<EditGroupData, AutoBaseViewHolder> {
    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param sectionHeadResId The section head layout id for each item
     * @param layoutResId      The layout resource id of each item.
     * @param data             A new list is created out of this one to avoid mutable list
     */
    public GroupSectionAdapter(int layoutResId, int sectionHeadResId, List data) {
        super(layoutResId, sectionHeadResId, data);
    }

    @Override
    protected void convertHead(AutoBaseViewHolder helper, final EditGroupData item) {
        helper.setText(R.id.tv_title, item.header);
    }


    @Override
    protected void convert(AutoBaseViewHolder helper, EditGroupData editData) {
        ReviewStudentData item = editData.t;
        helper.setChecked(R.id.rb_check, item.isCheck());
        Glide.with(mContext)
                .load(CommonApi.APP_AVATAR + item.getStudentId())
                .apply(RequestOptions.placeholderOf(R.drawable.public_img_default).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL))
                .into((ImageView) helper.getView(R.id.iv_icon));
        helper.setText(R.id.tv_name, item.getStudentName());
    }
}

